package com.alex.controller;

import com.alex.bean.YamlPerson;
import com.alex.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class HelloController {

    @Resource(name = "user01")
    private User user01;

    @Resource(name = "user02")
    private User user02;

    @ResponseBody
    @RequestMapping("/")
    public String handleIndex() {
        return "<h1>hello, spring boot!</h1>";
    }

    @ResponseBody
    @RequestMapping("/hello")
    public String handle01() {
        System.out.println("李云碧");
        return "hello, spring boot!";
    }

    @ResponseBody
    @RequestMapping("/test01")
    public String test01() {
        return "<h1>test01</h1>";
    }

    @ResponseBody
    @RequestMapping("/test02")
    public String test02() {
        return "<h1>test02 你好!</h1>";
    }

    @ResponseBody
    @RequestMapping("/test03")
    public Object test03() {
        return user01;
    }

    @ResponseBody
    @RequestMapping("/test04")
    public Object test04() {
        return user02;
    }

    @Autowired
    private YamlPerson yamlPerson;

    @ResponseBody
    @RequestMapping("/person")
    public Object person() {
        System.out.println("request: /person");
        return yamlPerson;
    }
}
